package cn.isjinhao.se.sql.grammar;

import cn.isjinhao.se.sql.function.evaluator.DefaultFunctionEvaluator;
import cn.isjinhao.se.sql.function.evaluator.FunctionEvaluator;
import cn.isjinhao.se.sql.grammar.statement.CurdParser;
import cn.isjinhao.se.sql.grammar.statement.create.InsertParser;
import cn.isjinhao.se.sql.grammar.statement.delete.DeleteParser;
import cn.isjinhao.se.sql.grammar.statement.retrieve.SelectParser;
import cn.isjinhao.se.sql.grammar.statement.update.UpdateParser;
import cn.isjinhao.se.sql.lexical.scan.DefaultScanner;
import cn.isjinhao.se.sql.lexical.scan.TokenSequence;

/**
 * @Author ISJINHAO
 * @Date 2021/7/24 22:27
 */
public class CurdStatementParserFactory {

    public static SelectParser createSelectParser(TokenSequence tokenSequence, FunctionEvaluator functionEvaluator) {
        return new SelectParser(tokenSequence, functionEvaluator);
    }

    public static SelectParser createSelectParser(String sql, FunctionEvaluator functionEvaluator) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createSelectParser(tokenSequence, functionEvaluator);
    }

    public static SelectParser createSelectParser(TokenSequence tokenSequence) {
        return createSelectParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static SelectParser createSelectParser(String sql) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createSelectParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }


    public static InsertParser createInsertParser(TokenSequence tokenSequence, FunctionEvaluator functionEvaluator) {
        return new InsertParser(tokenSequence, functionEvaluator);
    }

    public static InsertParser createInsertParser(String sql, FunctionEvaluator functionEvaluator) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createInsertParser(tokenSequence, functionEvaluator);
    }

    public static InsertParser createInsertParser(TokenSequence tokenSequence) {
        return createInsertParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static InsertParser createInsertParser(String sql) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createInsertParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }


    public static UpdateParser createUpdateParser(TokenSequence tokenSequence, FunctionEvaluator functionEvaluator) {
        return new UpdateParser(tokenSequence, functionEvaluator);
    }

    public static UpdateParser createUpdateParser(String sql, FunctionEvaluator functionEvaluator) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createUpdateParser(tokenSequence, functionEvaluator);
    }

    public static UpdateParser createUpdateParser(TokenSequence tokenSequence) {
        return createUpdateParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static UpdateParser createUpdateParser(String sql) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createUpdateParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }


    public static DeleteParser createDeleteParser(TokenSequence tokenSequence, FunctionEvaluator functionEvaluator) {
        return new DeleteParser(tokenSequence, functionEvaluator);
    }

    public static DeleteParser createDeleteParser(String sql, FunctionEvaluator functionEvaluator) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createDeleteParser(tokenSequence, functionEvaluator);
    }

    public static DeleteParser createDeleteParser(TokenSequence tokenSequence) {
        return createDeleteParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static DeleteParser createDeleteParser(String sql) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createDeleteParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static CurdParser createCurdParser(TokenSequence tokenSequence, FunctionEvaluator functionEvaluator) {
        return new CurdParser(tokenSequence, functionEvaluator);
    }

    public static CurdParser createCurdParser(String sql, FunctionEvaluator functionEvaluator) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createCurdParser(tokenSequence, functionEvaluator);
    }

    public static CurdParser createCurdParser(TokenSequence tokenSequence) {
        return createCurdParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

    public static CurdParser createCurdParser(String sql) {
        TokenSequence tokenSequence = new DefaultScanner(sql).scanTokens();
        return createCurdParser(tokenSequence, DefaultFunctionEvaluator.getInstance());
    }

}
